<?php

namespace App\Admin\Controllers;

use App\Models\Qiuzu;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class QiuzuController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Qiuzu(), function (Grid $grid) {
            $grid->model()->orderBy('id','desc');
            $grid->export()->filename('求组表单');
            $grid->column('id')->sortable();
            $grid->column('quyu','求租区域');
            $grid->column('mianji','求租面积');
            $grid->column('hangye','行业');
            $grid->column('zujin','承受租金范围');
            $grid->column('xingming','姓名');
            $grid->column('dianhua','电话');
            $grid->column('created_at')->sortable();
            $grid->column('updated_at')->sortable();
            $grid->disableActions();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Qiuzu(), function (Show $show) {
            $show->field('id');
            $show->field('quyu');
            $show->field('mianji');
            $show->field('hangye');
            $show->field('zujin');
            $show->field('xingming');
            $show->field('dianhua');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Qiuzu(), function (Form $form) {
            $form->display('id');
            $form->text('quyu');
            $form->text('mianji');
            $form->text('hangye');
            $form->text('zujin');
            $form->text('xingming');
            $form->text('dianhua');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
